set(CUR_LIB Hazel)

set (HazelDir  src/Hazel)

set(HazelEvent_SRC
    ${HazelDir}/Events/ApplicationEvent.h
    ${HazelDir}/Events/Event.h
    ${HazelDir}/Events/KeyEvent.h
    ${HazelDir}/Events/Mouse.h
)

set(Hazel_SRC 
    ${HazelEvent_SRC}
    ${HazelDir}/Application.h
    ${HazelDir}/Application.cpp
    ${HazelDir}/Core.h
    ${HazelDir}/EntryPoint.h
    ${HazelDir}/Layer.h
    ${HazelDir}/Layer.cpp
    ${HazelDir}/LayerStack.h
    ${HazelDir}/LayerStack.cpp
    ${HazelDir}/Log.h
    ${HazelDir}/Log.cpp
)

set(Platform_SRC 
    src/Platform/Windows/WindowsWindow.h
    src/Platform/Windows/WindowsWindow.cpp
)

set(Glad_SRC
    vendor/glad/include/glad/glad.h
    vendor/glad/include/KHR/khrplatform.h
    vendor/glad/src/glad.c
)

add_library(${CUR_LIB} SHARED
    ${Hazel_SRC}
    ${Platform_SRC}
    src/hzpch.cpp
    ${Glad_SRC}
)

target_include_directories(${CUR_LIB} PRIVATE 
    vendor/glad/include/
)

target_include_directories(${CUR_LIB} PUBLIC 
    src/
)

IF(UNIX)
    message("compiled on UNIX")
    target_compile_definitions(${CUR_LIB} PUBLIC HZ_ENABLE_ASSERTS=0)
ELSEIF(WIN32)
    message("compiled on WIN32")
    target_compile_definitions(${CUR_LIB} PUBLIC HZ_PLATFORM_WINDOWS)
    target_compile_definitions(${CUR_LIB} PRIVATE HZ_BUILD_DLL)
ENDIF(UNIX)

find_package(spdlog CONFIG REQUIRED)
target_link_libraries(${CUR_LIB} PUBLIC spdlog::spdlog)

# 链接GLFW库
find_package(glfw3 CONFIG REQUIRED)
target_link_libraries(${CUR_LIB} PRIVATE glfw)

IF(WIN32)
    target_link_libraries(${CUR_LIB} PRIVATE opengl32.lib)
ENDIF(WIN32)

IF(APPLE) 
    target_link_libraries(${CUR_LIB} PRIVATE "-framework OpenGL -framework Cocoa")
ENDIF()